package confidence;

import lombok.Builder;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

/**
 * 高潜力计算
 */
public class HighPotential {


    public static Potential highPotential(String original_aoi, String fusion_aoi, String original_poi,
                                   String fusion_poi, String original_village, String fusion_village) {

        if (StringUtils.isNotBlank(fusion_aoi) && StringUtils.isNotBlank(original_aoi)
                && fusion_aoi.length() > 2 && original_aoi.contains(fusion_aoi)) {
            return Potential.builder().type(1).reason("[原始地址-小区/AOI]包含[清洗-融合结果-小区/AOI]且[清洗-融合结果-小区/AOI]大于2个字符").build();
        }

        if (StringUtils.isNotBlank(original_aoi) && StringUtils.isNotBlank(fusion_aoi)
                && original_aoi.length() > 2 && fusion_aoi.contains(original_aoi)) {
            return Potential.builder().type(2).reason("[清洗-融合结果-小区/AOI]包含[原始地址-小区/AOI]且[原始地址-小区/AOI]大于2个字符").build();
        }

        if(StringUtils.isNotBlank(original_aoi) && StringUtils.isNotBlank(fusion_poi) && fusion_poi.contains(original_aoi)) {
            return Potential.builder().type(3).reason("[清洗-融合结果-地标/POI]包含[原始地址-小区/AOI]").build();
        }

        if(StringUtils.isNotBlank(original_aoi) && StringUtils.isNotBlank(fusion_poi) && original_aoi.contains(fusion_poi)) {
            return Potential.builder().type(4).reason("[原始地址-小区/AOI]包含[清洗-融合结果-地标/POI]").build();
        }

        if(StringUtils.isNotBlank(fusion_aoi) && StringUtils.isNotBlank(original_poi) && fusion_aoi.contains(original_poi)) {
            return Potential.builder().type(5).reason("[清洗-融合结果-小区/AOI]包含[原始地址-地标/POI]").build();
        }

        if(StringUtils.isNotBlank(original_poi) && StringUtils.isNotBlank(fusion_aoi) && original_poi.contains(fusion_aoi)) {
            return Potential.builder().type(6).reason("[原始地址-地标/POI]包含[清洗-融合结果-小区/AOI]").build();
        }

        if( StringUtils.isNotBlank(original_village) && StringUtils.isNotBlank(fusion_village) &&
            (original_village.contains("村") || original_village.contains("庄"))  && fusion_village.contains(original_village)) {
            return Potential.builder().type(7).reason("[原始地址-村/社区]包含村或庄且[清洗-融合结果-村/社区]包含[原始地址-村/社区]").build();
        }

        return Potential.builder().type(0).reason("未命中任何条件").build();
    }

    public static void main(String[] args) {
        System.out.println(HighPotential.highPotential("1234", "123", "","","","").toString());
        System.out.println(HighPotential.highPotential("123", "1234", "","","","").toString());

        System.out.println(HighPotential.highPotential("1234", "", "","123","","").toString());
        System.out.println(HighPotential.highPotential("123", "", "","1234","","").toString());

        System.out.println(HighPotential.highPotential("", "123", "1234","","","").toString());
        System.out.println(HighPotential.highPotential("", "1234", "123","","","").toString());

        System.out.println(HighPotential.highPotential("", "", "","","王村","小王村").toString());

        System.out.println(HighPotential.highPotential("", "", "","","","").toString());
    }


    @Builder
    @Data
    public static class Potential{
        private int type;
        private String reason;

        @Override
        public String toString() {
            return "Potential{" +
                    "type=" + type +
                    ", reason='" + reason + '\'' +
                    '}';
        }
    }

}
